package com.kele.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class RabbitMQApplicatioRunner implements ApplicationRunner {

    @Value("${ftl.queue}")
    private String QUEUE_NAME;

    private static final String EXCHANGE_NAME = "page_exchange_fanout2";
    @Override
    public void run(ApplicationArguments args) throws Exception {
        Exchange exchange = ExchangeBuilder.fanoutExchange(EXCHANGE_NAME).durable(true).build();
        Queue queue = QueueBuilder.durable(QUEUE_NAME).build();
        BindingBuilder.bind(queue).to(exchange).with("anything").noargs();
    }
}
